package objects;

import java.io.IOException;

public class GruObject extends AddressedObject {
	public DataObject[] fields = new DataObject[ 0 ];
	
	@Override
	public GruObject toGruObject() {
		return this;
	}
	
	@Override
	public void io() throws IOException {
		gruClass = objectIO( gruClass );
		if( read ) {
			fields = new DataObject[ gruClass.allFields.size() ];
			for( int n = 0; n < fields.length; n++ ) {
				fields[ n ] = gruClass.allFields.get( n ).gruClass.nativeClass.readValue( file );
			}
		} else {
			for( DataObject field : fields ) {
				field.writeValue( file );
			}
		}
	}

	@Override
	public DataObject newObject() {
		return new GruObject();
	}
}